package logic

import (
	"baidu/models/mysql"
	"context"

	"baidu/baidurpc/baidurpc"
	"baidu/baidurpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type PostShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewPostShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PostShowLogic {
	return &PostShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 帖子详情
func (l *PostShowLogic) PostShow(in *baidurpc.PostShowRequest) (*baidurpc.PostShowResponse, error) {
	// todo: add your logic here and delete this line

	var post mysql.Post
	mysql.DB.Debug().Where("id = ?", in.Id).Find(&post)

	return &baidurpc.PostShowResponse{
		Title:   post.Title,
		Context: post.Context,
		UserId:  post.UserId,
	}, nil
}
